qx.Class.define("bip.ui.categories.CategoryListView",
{
  extend : qx.ui.core.Widget,
  include : [qx.ui.form.MModelProperty],

  construct : function()
  {
    this.base(arguments);
    
    // initialize the layout
    var layout = new qx.ui.layout.Grid(4, 2);
    layout.setColumnFlex(1, 1);
    this._setLayout(layout);

    // create the widgets
    this._createChildControl("name");
    this._createChildControl("description");
    
  },

  properties :
  {
    appearance :
    {
      refine : true,
      init : "listitem"
    },
    
    name :
    {
      check : "String",
      apply : "_applyName",
      nullable : true
    },
    
    description :
    {
      check : "String",
      apply : "_applyDescription",
      nullable : true
    }
  },

  members :
  { 
    // overridden
    _createChildControlImpl : function(id)
    {
      var control;

      switch(id)
      {   
        case "name":
          control = new qx.ui.basic.Label(this.getName());
          control.setAnonymous(true);
          this._add(control, {row: 0, column: 0});
          break;
          
        case "description":
          control = new qx.ui.basic.Label(this.getDescription());
          control.setAnonymous(true);
          control.setRich(true);
          this._add(control, {row: 0, column: 1});
          break;
      }

      return control || this.base(arguments, id);
    },
    
    // property apply
    _applyName : function(value, old)
    {
      var name = this.getChildControl("name");
      name.setValue(value);
    },
    
    // property apply
    _applyDescription : function(value, old)
    {
      var desc = this.getChildControl("description");
      desc.setValue(value);
    }
    
  },
  
  destruct : function()
  {
    
  }
});